(function(){
    var $modal = $('#pop-modal');
    var validator = new Validator('safety-form',[
        {
            name: 'old-pass',
            display:"请输入旧密码",
            rules: 'required'
        },
        {
            name: 'new-pass',
            display:"请输入新密码|新密码最小是六位|新密码最大是20位|密码必须为整数",
            rules: 'required|min_length(6)|max_length(20)'
        }
    ],function(obj,evt){
        if(obj.errors){
            // 判断是否错误
            if (obj.errors[0] ==null) {
                if ($('input[name="new-pass"]').val()==$('input[name="reset-pass"]').val()) {

                    var oldPwd= $('input[name="old-pass"]').val();
                    var  newPwd= $('input[name="new-pass"]').val();
                    getJson(Domain+'/mbr/doUpdatePwd.do',{oldPwd:oldPwd,newPwd:newPwd},function (res) {
                        if(!res.success){
                            console.log(res);
                                $('.am-modal-bd').text(res.errorMessage);
                                $modal.modal();
                                setTimeout(function () {
                                $modal.modal('close');
                                },iWiating);

                        }else{
                           alert('密码修改成功')
                        }
                    })
                }else{
                     alert("二次输入的不一致");
                }
            }else{
                alert(obj.errors[0].message);
            }
            
        }
    })
    $('.btn').click(function(){
        console.log('ddddddd');
        validator.validate();
    })
})();